package com.ibiaoke.boss.controller;

import com.ibiaoke.boss.entity.SysUser;
import com.ibiaoke.common.base.BaseController;
import com.ibiaoke.common.base.Page;
import com.ibiaoke.common.response.Res;
import com.ibiaoke.goods.entity.Adjust;
import com.ibiaoke.goods.service.AdjustService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Date;
import java.util.List;

@Controller
public class BossAdjustController extends BaseController {

    private Logger logger = LoggerFactory.getLogger(this.getClass().getName());

    @Autowired
    AdjustService adjustService;

    @RequestMapping("/addAdjust")
    @ResponseBody
    public Res addAdjust(Adjust adjust,Integer shopId){
        SysUser user = getLoginUser();
        adjustService.addAdjust(user.getUserName(),shopId,adjust);
        logger.info("系统用户{}调货成功",user.getUserName());
        return Res.create();
    }


    @RequestMapping("/findAdjustList")
    @ResponseBody
    public  Res  findAdjustList(String goodName, Integer goodStockId, Integer goodId,Date adjustInTime,Date adjustEndTime, String outName,
                                String inName,Integer shopId,Page page){
        List<Adjust> adjustList =  adjustService.findAdjustList(goodName,goodStockId,goodId,adjustInTime,adjustEndTime,outName,inName,shopId,page);
        return  Res.create().addResponse("adjustList", adjustList).addResponse("page",page);
    }

}
